#ifndef __SPI_LCD_H__
#define __SPI_LCD_H__

#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"
#include "stdbool.h"

#include "common_api.h"
#include "luat_rtos.h"
#include "luat_debug.h"
#include "luat_gpio.h"
#include "platform_define.h"
#include "common_api.h"
#include "luat_rtos.h"
#include "luat_debug.h"
#include "luat_spi.h"




//引脚定义
#define LCD_RST_PIN HAL_GPIO_1   //复位引脚
#define LCD_RS_PIN  HAL_GPIO_10   //数据命令引脚
#define LCD_CS_PIN  HAL_GPIO_8    //片选引脚



#define __LCD_CS_Release()                        luat_gpio_set(LCD_CS_PIN, 1)
#define __LCD_CS_Select()                         luat_gpio_set(LCD_CS_PIN, 0)


#define   __LCD_RESET_Set()                     luat_gpio_set(LCD_RST_PIN, 1)
#define   __LCD_RESET_Release()                 luat_gpio_set(LCD_RST_PIN, 0)




#define  LCD_WRITE_DATA         luat_gpio_set(LCD_RS_PIN, 1)
#define  LCD_WRITE_CMD          luat_gpio_set(LCD_RS_PIN, 0)



typedef struct 
{
    uint8_t cmd;
    uint8_t data[25];
    uint8_t databytes; //No of data in data; bit 7 = delay after set; 0xFF = end of cmds.
} lcd_init_cmd_t;

//ѡ�����õ�ǰ����Ļ
#define ST7789_LCD 0
#define GC9306_LCD 0
#define GC9A01_LCD 1


void spi_lcd_init(void);          //��Ļ������ʼ��

void LCD_Write_Cmd(uint8_t cmd);
void LCD_Write_Data(uint8_t data);

void LCD_Set_Window(uint16_t x_s, uint16_t x_e, uint16_t y_s, uint16_t y_e);
void LCD_Display(uint16_t x_s, uint16_t x_e, uint16_t y_s, uint16_t y_e, uint16_t *data);
void LCD_Fill(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint16_t color);



void LCD_Quick_Clear_Fill(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint16_t color);


void LCD_Quick_Image(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint8_t * data);














#define WHITE         	 0xFFFF
#define BLACK         	 0x0000	  
#define BLUE           	 0x001F  
#define BRED             0XF81F
#define GRED 			       0XFFE0
#define GBLUE			       0X07FF
#define RED           	 0xF800
#define MAGENTA       	 0xF81F
#define GREEN         	 0x07E0
#define CYAN          	 0x7FFF
#define YELLOW        	 0xFFE0
#define BROWN 			     0XBC40 //��ɫ
#define BRRED 			     0XFC07 //�غ�ɫ
#define GRAY  			     0X8430 //��ɫ
#define DARKBLUE      	 0X01CF	//����ɫ
#define LIGHTBLUE      	 0X7D7C	//ǳ��ɫ  
#define GRAYBLUE       	 0X5458 //����ɫ
#define LIGHTGREEN     	 0X841F //ǳ��ɫ
#define LGRAY 			     0XC618 //ǳ��ɫ(PANNEL),���屳��ɫ
#define LGRAYBLUE        0XA651 //ǳ����ɫ(�м����ɫ)
#define LBBLUE           0X2B12 //ǳ����ɫ(ѡ����Ŀ�ķ�ɫ)



#endif